package online.shenme.day05;

import java.util.Objects;

public class ObjectTest {
    public static void main(String[] args) {
        Test01 name1 = new Test01("132", "name");
        Test01 name2 = new Test01("132", "name");
        System.out.println(name1.equals(name2));
        System.out.println(name1);
    }
}

class Test01{
    private String id;
    private String name;

    public Test01() {
    }

    public Test01(String id, String name) {
        this.id = id;
        this.name = name;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof Test01 test01)) return false;
        return Objects.equals(getId(), test01.getId()) && Objects.equals(getName(), test01.getName());
    }

    @Override
    public int hashCode() {
        return Objects.hash(getId(), getName());
    }

    @Override
    public String toString() {
        return "Test01{" +
                "id='" + id + '\'' +
                ", name='" + name + '\'' +
                '}';
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
